package com.restaurant.application.minifacade.data;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;
import java.lang.String;
import java.util.List;

public class PersonBO implements PickableBean {
    
    public static final String FN_NICKNAME = "nickName";
    public static final String FN_GENDER = "gender";
    public static final String FN_BIRTHDAY = "birthday";
    public static final String FN_PHONE = "phone";
    public static final String FN_ID = "id";
    
    public static final List<String> FIELD_NAMES = Lists.newArrayList(
             FN_NICKNAME,
             FN_GENDER,
             FN_BIRTHDAY,
             FN_PHONE,
             FN_ID);
    
    private String nickName;
    private String gender;
    private String birthday;
    private String phone;
    private String id;
    
    public PersonBO(String nickName, String gender, String birthday, String phone, String id) {
        setNickName(nickName);
        setGender(gender);
        setBirthday(birthday);
        setPhone(phone);
        setId(id);
    }
    
    public PersonBO() {
    }
    
    public PersonBO duplicate() {
        PersonBO result = new PersonBO();
        result.nickName = this.nickName;
        result.gender = this.gender;
        result.birthday = this.birthday;
        result.phone = this.phone;
        result.id = this.id;
        return result;
    }
    
    @Override
    public String toString() {
        return Convert.toJson(this);
    }
    
    public String getNickName() {
        return nickName;
    }
    
    public void  setNickName(String value) {
        this.nickName = value;
    }
    
    public PersonBO withNickName(String value) {
        setNickName(value);
        return this;
    }
    
    public PersonBO withNickName(String value, String defaultValue) {
        setNickName(value == null ? defaultValue : value);
        return this;
    }
    
    public String getGender() {
        return gender;
    }
    
    public void  setGender(String value) {
        this.gender = value;
    }
    
    public PersonBO withGender(String value) {
        setGender(value);
        return this;
    }
    
    public PersonBO withGender(String value, String defaultValue) {
        setGender(value == null ? defaultValue : value);
        return this;
    }
    
    public String getBirthday() {
        return birthday;
    }
    
    public void  setBirthday(String value) {
        this.birthday = value;
    }
    
    public PersonBO withBirthday(String value) {
        setBirthday(value);
        return this;
    }
    
    public PersonBO withBirthday(String value, String defaultValue) {
        setBirthday(value == null ? defaultValue : value);
        return this;
    }
    
    public String getPhone() {
        return phone;
    }
    
    public void  setPhone(String value) {
        this.phone = value;
    }
    
    public PersonBO withPhone(String value) {
        setPhone(value);
        return this;
    }
    
    public PersonBO withPhone(String value, String defaultValue) {
        setPhone(value == null ? defaultValue : value);
        return this;
    }
    
    public String getId() {
        return id;
    }
    
    public void  setId(String value) {
        this.id = value;
    }
    
    public PersonBO withId(String value) {
        setId(value);
        return this;
    }
    
    public PersonBO withId(String value, String defaultValue) {
        setId(value == null ? defaultValue : value);
        return this;
    }
    
    public Object getValueOf(String name) {
        switch(name) {
        case "nickName": return getNickName();
        case "gender": return getGender();
        case "birthday": return getBirthday();
        case "phone": return getPhone();
        case "id": return getId();
        }
        return null;
    }
    
    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }
    
    @Override
    public int hashCode() {
        return signature().hashCode();
    }
    
    @Override
    public boolean equals(Object o) {
        if(!(o instanceof PersonBO)) return false;
        return signature().equals(((PersonBO)o).signature());
    }
    
    public String signature() {
        throw new RuntimeException("Bean PersonBO has no signature defined, no hash code or equals possible.");
    }
}
